using UnityEngine;
using System.Collections;
using System.Collections.Generic;

[AddComponentMenu("GK/Sequencer/gkSequencer")]
[RequireComponent(typeof(gkSequencerEditorView))]
/// \class  gkSequencer
/// \brief 	The action sequencer
public class gkSequencer : MonoBehaviour
{	
	/// \brief  Add a track
	public void AddTrack()
	{
		GameObject rNewTrackGameObject;
		
		// Create a new game object to contain the track component
		rNewTrackGameObject = new GameObject("Track");
		
		// Attach it to the sequence game object
		rNewTrackGameObject.transform.parent = gameObject.transform;
		
		// Add a new track component to the track object
		rNewTrackGameObject.AddComponent<gkSequencerTrack>();
	}
	
	/// \brief  Delete the last track
	public void DeleteLastTrack()
	{
		gkSequencerTrack[] rTracks;
		
		// Try to grab the last track
		rTracks = GetComponentsInChildren<gkSequencerTrack>();
		if(rTracks.Length > 0)
		{
			// Destroy the track game object
			DestroyImmediate(rTracks[rTracks.Length - 1].gameObject);
		}
	}
}